package com.mall.server.service;

import com.mall.dubbo.api.SmsFlashPromotionSessionApi;
import com.tanhua.model.domain.SmsFlashPromotionSession;
import com.tanhua.model.vo.SmsFlashPromotionSessionDetail;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FlashSessionService {
    @DubboReference
    private SmsFlashPromotionSessionApi smsFlashPromotionSessionApi;


    /**
     * 查询秒杀活动

     */
    public List<SmsFlashPromotionSession> flashSessionList() {
        return smsFlashPromotionSessionApi.flashSessionList();
    }

    /**
     * 修改秒杀时间段是否启用
     * @param id
     * @param starts
     */
    public void updateStatus(Long id, Integer starts) {
        smsFlashPromotionSessionApi.updateStatus(id,starts);
    }

    /**
     * 添加秒杀时间段
     * @param smsFlashPromotionSession
     * @return
     */
    public void create(SmsFlashPromotionSession smsFlashPromotionSession) {
        smsFlashPromotionSessionApi.create(smsFlashPromotionSession);
    }

    /**
     * 修改秒杀时间段
     * @param smsFlashPromotionSession
     * @return
     */
    public void update(SmsFlashPromotionSession smsFlashPromotionSession) {
        smsFlashPromotionSessionApi.update(smsFlashPromotionSession);
    }

    /**
     * 删除秒杀时间
     * @param id
     * @return
     */
    public void delete(Long id) {
        smsFlashPromotionSessionApi.delete(id);
    }

    /**
     * 根据flashPromotionId 查询sms_flash_promotion_product_relation 得到 sms_flash_promotion_session 集合返回
     * @param flashPromotionId
     * @return
     */
    public List<SmsFlashPromotionSessionDetail> findFlashPromotionIdList(Long flashPromotionId) {
        return smsFlashPromotionSessionApi.findFlashPromotionIdList(flashPromotionId);
    }
}
